<script type="text/javascript" src="<?= $this->config->base_url(); ?>assets/js/jquery-1.4.3.min.js"></script>
<script type="text/javascript" src="<?= $this->config->base_url(); ?>assets/js/jquery-ui.js"></script>
<link rel="stylesheet" href="<?= $this->config->base_url(); ?>assets/css/jquery-ui.css" type="text/css" charset="utf-8" />

<script>

$(function() {
        var scntDiv = $('#p_scents');
        var i = $('#p_scents tr').size() + 1;
     $('.addScnt').live('click', function() {
                $('<tr id="dd'+ i +'"> <td><input type="text" class="span8"  name="sl_no[]" onchange="get_date('+i+')"  id="sl_no'+i+'" /></td>  <td><input type="text" class="span8" name="case_no[]" onblur="get_docket_no1((this.value),'+i+')"id="case_no'+i+'" /></td><td><input type="text" class="span8"  name="docket_no[]" id="docket_no'+i+'" /></td> <td><input type="text" class="span8 date1" data-date-format="yyyy/mm/dd" name="received_date[]"  id="received_date'+i+'" /></td><td><input type="text" class="span8" name="response[]"  id="response'+i+'" /></td><td><a href="#" class="addScnt">ADD</a>&nbsp;&nbsp;&nbsp;<a href="#" id="'+i+'" class="remScnt">Remove</a></td></tr>').appendTo(scntDiv);
                i++;
				
                return false;
        });
        
        $('.remScnt').live('click', function() { 
       	
	            if( i > 2 ) {
                        
						$(this).parents('tr').remove();
                        i--;
                }
                return false;
		
        });
});










</script>
<div class="header">
            
            <h1 class="page-title">New Received Docket</h1>
        </div>
        
                <ul class="breadcrumb">
            <li><a href="<?php echo site_url('/admin/docket/view_all')?>">ALL Docket</a><span class="divider">/</span></li>
            <li class="active">New Received</li>
        </ul>
<div class="row-fluid">

<form method="post" action="<?php echo site_url(); ?>/admin/docket/new_dispatch">



<div class="span12 pad_all">
<table width="100%" class="table table-bordered" >
  <tr class="info">
               <td><b>SL No.</b></td>
               <td><b>Case No.</b></td>
			  <td><b>Docket No.</b></td>
              <td><b>Received Date</b></td>
			  <td><b>Response</b></td>
              <td><b>Options</b></td>
             </tr>
			
 <tbody id="p_scents">           
  <tr><label for="p_scnts">
    <td><input type="text" class="span8" name='sl_no[]' id="sl_no" /></td>
    <td><input type="text" class="span8" name="case_no[]" id="case_no" onblur="get_docket_no(this.value)"; /></td>
	 <td><input type="text" class="span8"  id="docket_no"  name='docket_no[]'/></td>
	 <td><input type="text" class="span8 date1"data-date-format="yyyy/mm/dd" name="received_date[]"  id="received_date"  /></td>
	  <td><input type="text" class="span8" name="response[]"  id="response" /></td>
  <td><a href="#" class="addScnt">ADD</a></td>
 </label> </tr>
 
  </tbody>
</table>
<br>
<br>
<p align="right"><?php echo form_submit('submit', 'Save', 'class="btn btn-success"');?></p>
</form>
</div>
</div>
<script>

$(document).ready(function(){
	$('.date1').datepicker({ dateFormat: 'yy-mm-dd' });

	
})
function get_date(i)
{ 
var t='#'+'received_date'+i
	$(t).datepicker({ dateFormat: 'yy-mm-dd' });
}

 function get_docket_no(docket)
 {
	var id=docket

		$.post("<?= site_url('admin/docket/get_docket_no')?>",{ id:id }, function(msg){ 
		if(msg!=""){

				$('#docket_no').val(msg);	
               
			}else
			
			{
				$('#docket_no').val(""),
			
				alert(' Sorry No Docket No. Exist With This Case No.!!')
				}
		
		})
	
 
 }
  function get_docket_no1(docket,i)
 { 
  	var t='#'+'docket_no'+i
	var date='#'+'received_date'+i
	var id=docket

		$.post("<?= site_url('admin/docket/get_docket_no')?>",{ id:id }, function(msg){ 
		if(msg!=""){

				
				$(t).val(msg);
                $(date).datepicker({ dateFormat: 'yy-mm-dd' });
			}else
			
			{
				$(t).val(""),
				 $(date).datepicker({ dateFormat: 'yy-mm-dd' });
				alert('Sorry No Docket No. Exist With This Case No.!!')
				}
		
		})
	
 
 }


</script>